package com.jtpay.sdk.activity;

import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.jtpay.sdk.R;
import com.jtpay.sdk.base.BaseActivity;
import com.jtpay.sdk.util.AuthUtil;

import apiUtils.models.PayInfo;
import butterknife.Bind;
import butterknife.OnClick;


public class PayResultsActivity extends BaseActivity {
    @Bind(R.id.layout_title_textName)
    TextView mTitleTextView;
    @Bind(R.id.continue_test)
    Button mContiuneTextBtn;
    @Bind(R.id.log_out)
    TextView mLogOutTv;
    @Bind(R.id.resultes_status_imageView)
    ImageView mStatusImageView;
    @Bind(R.id.results_status_TextView)
    TextView mStatusTextView;
    @Bind(R.id.app_id_tv)
    TextView mAppIdTextView;
    @Bind(R.id.app_name_tv)
    TextView mAppNameTextView;
    @Bind(R.id.order_number_tv)
    TextView mOrderNumberTextView;
    @Bind(R.id.order_money_tv)
    TextView mOrderMoneyTextView;
    @Bind(R.id.pay_product_tv)
    TextView mProductTextView;
    @Bind(R.id.channel_name_tv)
    TextView mChannelNameTextView;

    private int mPayStatus;

    @Override
    protected void initView() {
        mTitleTextView.setText(R.string.pay_result);
        mStatusImageView.setImageResource(mPayStatus == 1 ? R.drawable.pay_success : R.drawable.pay_failure);
        mStatusTextView.setText(mPayStatus == 1 ? R.string.pay_success : R.string.pay_not_success);
        mAppIdTextView.setText(PayInfo.getInstance().getModel().getApplicationId());
        mAppNameTextView.setText(PayInfo.getInstance().getModel().getApplicationName());
        mOrderNumberTextView.setText(PayInfo.getInstance().getModel().getOrderNumber());
        mOrderMoneyTextView.setText(PayInfo.getInstance().getModel().getOrderMoney());
        mProductTextView.setText(PayInfo.getInstance().getPayTypeName());
        mChannelNameTextView.setText(PayInfo.getInstance().getChannelName());
    }

    @OnClick({R.id.continue_test, R.id.log_out, R.id.layout_title_iv_left})
    void buttonClick(View view) {
        switch (view.getId()) {
            case R.id.continue_test:
                finish();
                break;
            case R.id.log_out:
                AuthUtil.getInstance().logOut();
                break;
            case R.id.layout_title_iv_left:
                finish();
                break;
            default:

                break;
        }
    }

    @Override
    protected void initData() {
        mPayStatus = getIntent().getIntExtra("payStatus", 0);
    }

    @Override
    protected int setView() {
        return R.layout.activity_pay_results;
    }
}
